package com.ktjy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.mapper.CstServiceMapper;
import com.ktjy.pojo.CstService;
import com.ktjy.pojo.Customer;
import com.ktjy.service.ICstServiceService;
import com.ktjy.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-01-16
 */
@Service
public class CstServiceServiceImpl extends ServiceImpl<CstServiceMapper, CstService> implements ICstServiceService {
    @Autowired
    ICustomerService iCustomerService;

    @Override
    public boolean save(CstService cstService) {
        //设置创建时间为当前时间
        cstService.setSvrCreateDate(LocalDateTime.now());
        //刚创建的服务为新创建状态
        cstService.setSvrStatus("新创建");
        //设置客户名称
        Customer customer=iCustomerService.getById(cstService.getSvrCustNo());
        cstService.setSvrCustName(customer.getCustName());

        return super.save(cstService);
    }
}
